package pl.nazaweb.imedproplus.model.entity;

import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import pl.nazaweb.imedproplus.model.interfaces.IDictionary;

@Entity
@Table(name = "dictionary")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Dictionary.findAll", query = "SELECT d FROM Dictionary d"),
    @NamedQuery(name = "Dictionary.findById", query = "SELECT d FROM Dictionary d WHERE d.id = :id"),
    @NamedQuery(name = "Dictionary.findByCode", query = "SELECT d FROM Dictionary d WHERE d.code = :code"),
    @NamedQuery(name = "Dictionary.findByName", query = "SELECT d FROM Dictionary d WHERE d.name = :name"),
    @NamedQuery(name = "Dictionary.findBySecondValue", query = "SELECT d FROM Dictionary d WHERE d.secondValue = :secondValue")})
public class Dictionary implements Serializable, IDictionary {
    private static final long serialVersionUID = 1L;
    @Id
    @SequenceGenerator(name = "dictionary_sequence_", sequenceName = "dictionary_sequence", allocationSize=1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "dictionary_sequence_")
    @Basic(optional = false)
    @NotNull
    @Column(name = "id")
    private Long id;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 10)
    @Column(name = "code")
    private String code;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 250)
    @Column(name = "name")
    private String name;
    @Size(max = 250)
    @Column(name = "second_value")
    private String secondValue;

    public Dictionary() {
    }

    public Dictionary(Long id) {
        this.id = id;
    }

    public Dictionary(Long id, String code, String name) {
        this.id = id;
        this.code = code;
        this.name = name;
    }

    @Override
    public Long getId() {
        return id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public String getCode() {
        return code;
    }

    @Override
    public void setCode(String code) {
        this.code = code;
    }

    @Override
    public String getName() {
        return name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String getSecondValue() {
        return secondValue;
    }

    @Override
    public void setSecondValue(String secondValue) {
        this.secondValue = secondValue;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Dictionary)) {
            return false;
        }
        Dictionary other = (Dictionary) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pl.nazaweb.imedproplus.model.entity.Dictionary[ id=" + id + " ]";
    }

}
